[contents] [prev] [next] [top] [bottom] (10 out of 12)

Modules

Expressions that define modules, or that set the current working module, are only allowed at the top level.

inModuleExpr 	::=	in module symbol 
moduleDefExpr	::=	module symbol [ moduleOptions ] end 

Each module option can be repeated any number of times, and in any order, within the module definition expression.

moduleOptions	::=	[ moduleOption ]* 
moduleOption	::=	exports [ readonly ] \ 
			[ inst[ance] var[iable]s ] symbolSeq 
	|	uses symbolSeq 
	|	uses symbol [ with usesOptions ] end 
symbolSeq	::=	symbol [ , symbol ]* 

A module must explicitly list each name that it exports. Names of classes, objects, global variables, global functions, and generic functions, including getter and setter methods, must be explicitly listed in an exports clause.

Two syntactic choices are available in a module definition expression for using other modules. A uses clause lists a module or modules that are imported as a whole into the module. A uses . . . with clause allows for additional restrictions on how names are imported from another module. A uses . . . with clause contains a list of options. Each uses . . . with option can be repeated any number of times, and in any order.

usesOptions	::=	[ usesOption ]* 
usesOption	::=	imports everything 
	|	imports [ readonly ] \ 
			[ inst[ance] var[iable]s ] symbolSeq 
	|	exports everything 
	|	exports [ readonly ] \ 
			[ inst[ance] var[iable]s ] symbolSeq 
	|	prefix symbol 
	|	excludes [ readonly ] \ 
			[ inst[ance] var[iable]s ] symbolSeq 
	|	renames [ readonly ] \ 
			[ inst[ance] var[iable]s ] renameSeq 
renameSeq	::=	symbol : symbol [ , symbol : symbol ]*

Each uses . . . with option provides functionality for handling names that are imported into modules. Names that are imported from another module can be specified individually, or a module can import every name. Names that are imported can be exported again to other modules that use the current module. Names can also be excluded or renamed. An importing module can prefix all names from a given module that it uses.


This document is part of the ScriptX Language Guide, one of the volumes of the ScriptX Technical Reference Series. ScriptX is developed by the ScriptX Engineering Team at Apple Computer, successor to the Kaleida Engineering Team at Kaleida Labs, Inc.

Copyright 1996 Apple Computer, Inc. All Rights Reserved.